<template lang="pug">
  .sinature.page
</template>

<script>
import $AUTH from '@/utils/auth'
import { Toast } from 'vant'

export default {
  name: 'signature',
  data() {
    return {
      toast: null
    }
  },
  created() {
    let url = window.location.href
    let data = $AUTH.getHrefData(url)

    this.toast = Toast.loading({
      duration: 0,       // 持续展示 toast
      forbidClick: true, // 禁用背景点击
      loadingType: 'spinner',
      message: '微信授权中'
    })

    if(data) {
      let panoId = data.pano_id

      // 写入cookie
      let userCookieStr = ''
      for(var k in data) {
        userCookieStr += k + '=' + encodeURIComponent(data[k]) + '&'
      }
      userCookieStr = userCookieStr.slice(0, -1)
      $VM.$AUTH.setToken(userCookieStr)

      // 845定制
      if ($globalconfig.MODULES.IS_LANJIUKJ_PROGRAM_OPEN) {
        // window.location.replace($globalconfig.URLS.PANO_VIEW_PREFIX + panoId)
        // setTimeout(() => {
        //   window.history.go(0)
        // }, 200)

        this.$store.dispatch('initData', {panoId: panoId, ovvId: this.$route.query.ovv})
        this.$router.push(`/panoview/${data.pano_id}`)
        delete data.pano_id
      } else {
        this.$store.dispatch('initData', {panoId: panoId, ovvId: this.$route.query.ovv})
        this.$router.push(`/panoview/${data.pano_id}`)
        delete data.pano_id
      }
    }
  },
  mounted() {
    this.toast.clear()
  }
}
</script>

<style lang="stylus">
// .sinature
  // background-color: #fff
</style>
